#include "stdafx.h"
#include "FlashSecurityPolicy.h"

void FlashSecurityPolicyNet::onAccept(EssAcceptor* acceptor, EssConnector* connector)
{
	char* ip;
	u_short port;
	if (connector->getPeerName(&ip, &port))
	{
		char log[MAX_PATH] = {0};
		sprintf_s(log, "Accept a new client with IP %s, Port %d.\n", ip, port);
		mLog += log;
	}
	char retBuf[1024] = {0};
	sprintf_s(retBuf, "<?xml version=\"1.0\"?><cross-domain-policy><site-control permitted-cross-domain-policies=\"all\"/><allow-access-from domain=\"*\" to-ports=\"*\"/></cross-domain-policy>\0");
	connector->sendSock(retBuf, strlen(retBuf));
}

bool FlashSecurityPolicyNet::onReceive(EssConnector* connector)
{
	char* ip;
	u_short port;
	if (connector->getPeerName(&ip, &port))
	{
		//
	}
	return true;
}

void FlashSecurityPolicyNet::onDisconnect(EssConnector* connector)
{
	char* ip;
	u_short port;
	if (connector->getPeerName(&ip, &port))
	{
		char log[MAX_PATH] = {0};
		sprintf_s(log, "A client disconnect with IP %s, Port %d.\n", ip, port);
		mLog += log;
	}
	removeConnector(connector);
}